class Solution(object):
    def rob(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if len(nums) == 0:
            return 0
        yes = nums[0]
        no = 0
        for i in range(1, len(nums)):
            temp = max(yes, no)
            #  现在不抢 要从前面的最优解里选最大值
            yes = nums[i]+no
            no = temp
        return max(yes, no)
